package com.xhs.hawaii.common.utils.excel;


import java.util.HashMap;
import java.util.Map;

/**
 * @author tangchuang
 * @version 1.0
 * @since 2018/1/25
 */
public class MapUtils {

    public static <K, V> Builder<K, V> builder() {
        return new Builder<K, V>(new HashMap());
    }

    public static <K, V> Builder<K, V> builder(Map<K, V> map) {
        return new Builder(map);
    }

    public static class Builder<K, V> {

        private Map<K, V> map;

        private Builder(Map<K, V> map) {
            this.map = map;
        }

        public Builder<K, V> setMap(Map<K, V> map) {
            map.putAll(this.map);
            this.map.clear();
            this.map = map;
            return this;
        }

        public Builder<K, V> put(K key, V value) {
            map.put(key, value);
            return this;
        }

        public Map<K, V> build() {
            return map;
        }

    }


}
